package org.dromara.tearoom.mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.tearoom.domain.TerRechargeRules;
import org.dromara.tearoom.domain.vo.TerRechargeRulesVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;

/**
 * 充值规则Mapper接口
 *
 * @author xch
 * @date 2025-05-07
 */
public interface TerRechargeRulesMapper extends BaseMapperPlus<TerRechargeRules, TerRechargeRulesVo> {
    @Select("SELECT * FROM ter_recharge_rules " +
            "WHERE max_amount>=#{amount}  " +
            "AND ( min_amount <= #{amount} OR max_amount IS NULL) " +
            "AND start_time <= NOW() AND end_time >= NOW() " +
            "ORDER BY reward_value DESC LIMIT 1")
    TerRechargeRules selectMatchedRule(@Param("amount") Integer amount);
}
